#pragma once

#include <map>
#include <atomic>
#include <functional>
#include <boost/property_tree/json_parser.hpp>
#include "tcp_message.h"
#include "rockapi.h"
#include "app_common.h"
#include <boost/signals2.hpp>

using MessageType_t = std::map<std::string, int>;
class MessageHandlerBase
{
public:
    MessageHandlerBase() = default;
    MessageHandlerBase(const MessageType_t& messageTypes) {}
    virtual ~MessageHandlerBase() {}
    virtual void readBody(TcpSessionMessage_t msg)  {}
    virtual void start()  {}
public:
    boost::signals2::signal<void(TcpSessionMessage_t)> sendTcpMessageSignal;
};

class MessageHandler : public MessageHandlerBase
{
public:

    MessageHandler(const MessageType_t& messageTypes);
    ~MessageHandler() {}
    void readBody(TcpSessionMessage_t msg);
    void start();

private:
    MessageHandler() = delete;

    TcpMessage_t onHeartReq(const TcpMessage_t& msg);
    TcpMessage_t onLoginReq(const TcpMessage_t& msg);
    TcpMessage_t onLogoutReq(const TcpMessage_t& msg);
 
    MessageType_t _messageTypes;
};